﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace lyAdmin.Entity.Bean
{
    public class QueryBean
    {
        private PageBean page = new PageBean() { Page = 0, Size = 0 };

        private SortBean sort = new SortBean() { Field = "Id", Type = "desc" };
        private List<FieldsBean> fields = new List<FieldsBean>();

        /// <summary>
        /// 查询字段列表
        /// </summary>
        public List<FieldsBean> Fields {
            get {
                bool bo = false;
                for(int i = 0; i < fields.Count; i++)
                    if (fields[i].Field.ToLower() == "state")
                    {
                        bo = true;
                        break;
                    }
                if (!bo)
                    fields.Add(new FieldsBean() { Field = "state", Type = "gt", Value = "-1" });
                return fields;
            }
            set =>fields=value; }
        /// <summary>
        /// 排序
        /// </summary> 
        public SortBean Sort { get => sort; set => sort = value; }
        /// <summary>
        /// 分页
        /// </summary> 
        public PageBean Page { get => page; set => page = value; }

    }
}
